var qqmapsdk, _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
        return typeof t;
    } : function(t) {
        return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
    },
    a = getApp(),
    util = require("../../utils/util.js"),
    QQMapWX = require("../../utils/qqmap-wx-jssdk.js");

Page({
    data: {
        sortList: [{
            sort: "综合排序",
            image: ""
        }, {
            sort: "销量最高",
            image: ""
        }],
        params: {
            nopsf: 2,
            nostart: 2,
            yhhd: ""
        },
        issx: !1,
        selected: 1,
        animationData: "",
        location: "",
        characteristicSelected: [!1, !1],
        discountSelected: null,
        pagenum: 1,
        storelist: [],
        bfstorelist: [],
        mygd: !1,
        jzgd: !0,
        isjzz: !0
    },
    onTapTag: function(t) {
        var a = this.data.params;
        "1" == t.currentTarget.dataset.index && (a.by = "juli asc");
        "2" == t.currentTarget.dataset.index && (a.by = "sales desc");
        this.setData({
                sortSelected: this.data.sortList[0].sort,
                selected: t.currentTarget.dataset.index,
                params: a,
                pagenum: 1,
                storelist: [],
                bfstorelist: [],
                mygd: !1,
                jzgd: !0
            }),
            this.getstorelist();
    },
    sortSelected: function(t) {
        var a = this.data.params;
        "0" == t.currentTarget.dataset.sortindex && (a.by = "number asc"),
            "1" == t.currentTarget.dataset.sortindex && (a.by = "score desc"),
            "2" == t.currentTarget.dataset.sortindex && (a.by = "start_at asc"),
            "3" == t.currentTarget.dataset.sortindex && (a.by = "ps_money asc"),
            this.setData({
                selected: t.currentTarget.dataset.index,
                sortSelected: this.data.sortList[t.currentTarget.dataset.sortindex].sort,
                params: a,
                pagenum: 1,
                storelist: [],
                bfstorelist: [],
                mygd: !1,
                jzgd: !0
            }),
            this.getstorelist();
    },
    onShow: function() {
        if (wx.getStorageSync("index_Refresh")) {
            wx.setStorageSync("index_Refresh", false);
            let o = {};
            o.lat = wx.getStorageSync("index_lat");
            o.lng = wx.getStorageSync("index_lng");;
            this.setData({
                weizhi: wx.getStorageSync("index_addresses"),
                params: o,
                issx: !1,
                selected: 1,
                location: "",
                characteristicSelected: [!1, !1],
                discountSelected: null,
                selectedNumb: 0,
                sortSelected: "综合排序",
                pagenum: 1,
                storelist: [],
                bfstorelist: [],
                mygd: !1,
                jzgd: !0
            });
            this.getstorelist();
        }
    },
    dwreLoad: function() {
        var i = this,
            o = this.data.params;
        wx.getLocation({
            type: "wgs84",
            success: function(t) {
                var e = t.latitude,
                    s = t.longitude,
                    n = e + "," + s;
                qqmapsdk.reverseGeocoder({
                    location: {
                        latitude: e,
                        longitude: s
                    },
                    coord_type: 1,
                    success: function(t) {
                        var e = t.result.ad_info.location;
                        o.lat = e.lat,
                            o.by = o.by == undefined ? "juli asc" : o.by,
                            o.lng = e.lng,
                            i.setData({
                                weizhi: t.result.formatted_addresses.recommend,
                                startjwd: e,
                                params: o,
                                not_dingwei: true
                            }),
                            i.getstorelist();
                        wx.setStorageSync("index_addresses", t.result.formatted_addresses.recommend);
                    }
                });
            },
            fail: function() {
                wx.getSetting({
                    success: function(t) {
                        0 == t.authSetting["scope.userLocation"] && wx.showModal({
                            title: "提示",
                            content: "您点击了拒绝授权,无法正常使用功能，点击确定重新获取授权。",
                            showCancel: !1,
                            success: function(t) {
                                t.confirm && (wx.openSetting({
                                    success: function(t) {
                                        t.authSetting["scope.userLocation"],
                                            i.dwreLoad();
                                        i.onLoad();
                                    }
                                }));
                            }
                        });
                    }
                });
            }
        });
    },
    getstorelist: function() {
        var n = this,
            i = n.data.pagenum;
        n.data.params.page = i,
            n.data.params.pagesize = 10,
            n.setData({
                isjzz: !0
            }),
            a.util.request({
                url: "entry/wxapp/StoreList",
                cachetime: "0",
                data: n.data.params,
                success: function(t) {
                    t.data.length < 10 ? n.setData({
                        mygd: !0,
                        jzgd: !0,
                        isjzz: !1
                    }) : n.setData({
                        jzgd: !0,
                        pagenum: i + 1,
                        isjzz: !1
                    });
                    var a = n.data.bfstorelist;
                    a = function(t) {
                        for (var a = [], e = 0; e < t.length; e++) - 1 == a.indexOf(t[e]) && a.push(t[e]);
                        return a;
                    }(a = a.concat(t.data));
                    for (var e = 0; e < t.data.length; e++) {
                        "0.0" == t.data[e].sales && (t.data[e].sales = "5.0");
                        var s = parseFloat(t.data[e].juli);
                        t.data[e].aa = s < 1e3 ? s + "m" : (s / 1e3).toFixed(2) + "km",
                            t.data[e].aa1 = s,
                            n.setData({
                                storelist: a,
                                bfstorelist: a,
                                isxlsxz: !1
                            });
                    }
                }
            });
    },
    jumps: function(t) {
        var a = t.currentTarget.dataset.id,
            e = t.currentTarget.dataset.name,
            s = t.currentTarget.dataset.appid,
            n = t.currentTarget.dataset.src,
            i = t.currentTarget.dataset.wb_src,
            o = t.currentTarget.dataset.type;
        1 == o ? (wx.navigateTo({
            url: n
        })) : 2 == o ? (wx.setStorageSync("vr", i), wx.navigateTo({
            url: "../car/car"
        })) : 3 == o && wx.navigateToMiniProgram({
            appId: s
        });
    },
    tzsjxq: function(t) {
        let julis = t.currentTarget.dataset.julis;
        1 == t.currentTarget.dataset.type ? (getApp().sjid = t.currentTarget.dataset.sjid,
            wx.navigateTo({
                url: "/zh_cjdianc/pages/seller/index"
            })) : "1" == this.data.mdxx.is_tzms ? (getApp().sjid = t.currentTarget.dataset.sjid,
            wx.navigateTo({
                url: "/zh_cjdianc/pages/seller/index"
            })) : wx.navigateTo({
            url: "/zh_cjdianc/pages/takeout/takeoutindex?juli=" + julis + "&storeid=" + t.currentTarget.dataset.sjid
        });
    },
    qxd: function() {
        this.setData({
            istjhb: !1
        });
    },
    sssj: function() {
        wx.navigateTo({
            url: "sssj"
        });
    },
    dingwei: function() {
        wx.navigateTo({
            url: "dingwei"
        });
    },
    onLoad: function(t) {
        var i = this;
        i.setData({
            isxlsxz: !0
        });
        a.setNavigationBarColor(this);
        a.pageOnLoad(this);
        a.getUserInfo(function(s) {
            a.util.request({
                url: "entry/wxapp/CouponSet",
                cachetime: "0",
                success: function(t) {
                    i.setData({
                        CouponSet: t.data
                    });
                }
            });
        });
        a.util.request({
            url: "entry/wxapp/system",
            cachetime: "0",
            success: function(t) {
                var n = t.data;
                qqmapsdk = new QQMapWX({
                    key: t.data.map_key
                }), wx.setNavigationBarTitle({
                    title: t.data.url_name
                }), i.setData({
                    mdxx: t.data
                });
                if (i.data.not_dingwei != true) {
                    i.dwreLoad();
                } else {
                    i.getstorelist();
                }
                wx.setStorageSync("bqxx", t.data);
            }
        });
        // 请求广告
        a.util.request({
            url: "entry/wxapp/ad",
            cachetime: "0",
            success: function(t) {
                for (var a = [], e = [], s = [], n = 0; n < t.data.length; n++) "1" == t.data[n].type && a.push(t.data[n]),
                    "3" == t.data[n].type && e.push(t.data[n]), "4" == t.data[n].type && s.push(t.data[n]);
                i.setData({
                    toplb: a,
                    zblb: e,
                    dblb: s
                });
            }
        });
    },
    onPullDownRefresh: function() {
        this.setData({
                issx: !1,
                selected: 1,
                location: "",
                characteristicSelected: [!1, !1],
                discountSelected: null,
                selectedNumb: 0,
                sortSelected: "综合排序",
                pagenum: 1,
                storelist: [],
                bfstorelist: [],
                mygd: !1,
                jzgd: !0
            }), this.data.isxlsxz || (this.setData({
                jzgd: !1
            }), this.onLoad()),
            wx.stopPullDownRefresh();
    },
    onReachBottom: function() {
        this.data.mygd || !this.data.jzgd || this.data.isjzz || (this.setData({
            jzgd: !1
        }), this.getstorelist());
    },
    onShareAppMessage: function() {
        return {
            title: "" == this.data.mdxx.fx_title ? this.data.mdxx.url_name : this.data.mdxx.fx_title,
            path: "/zh_cjdianc/pages/Liar/loginindex",
            success: function(t) {},
            fail: function(t) {}
        };
    }
});